package com.chf.job.service.impl;

import com.chf.job.dao.WorkShowMapper;
import com.chf.job.pojo.WorkShow;
import com.chf.job.service.WorkShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkShowServiceImpl implements WorkShowService {
    @Autowired
    private WorkShowMapper workShowMapper;
    /**
     * 添加作品展示
     * @param workShow
     * @return
     */
    @Override
    public int addWorkShow(WorkShow workShow) {
        if (workShow.getId() == null) {
            WorkShow show = new WorkShow();
            show.setResumeId(workShow.getResumeId());
            show.setWorkUrl(workShow.getWorkUrl());
            show.setWorkCaption(workShow.getWorkCaption());
            return workShowMapper.insertSelective(show);
        }
        WorkShow show = new WorkShow();
        show.setId(workShow.getId());
        show.setResumeId(workShow.getResumeId());
        show.setWorkUrl(workShow.getWorkUrl());
        show.setWorkCaption(workShow.getWorkCaption());
        return workShowMapper.updateByPrimaryKeySelective(show);

    }

    /**
     * 根据简历id查询作品展示集合
     * @param id
     * @return
     */
    @Override
    public List<WorkShow> getById(Integer id) {
        return  workShowMapper.selectByResumeId(id);
    }

    /**
     * 根据d删除作品展示
     * @param resumeId
     * @return
     */
    @Override
    public int deleteByResumeId(Integer resumeId) {
        return workShowMapper.deleteByPrimaryKey(resumeId);
    }
}
